package data;

import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;
import com.mongodb.MongoException;
import com.mongodb.MongoOptions;

import java.net.UnknownHostException;

public class Data {
static Mongo m = null;
	
	static String name = "email";
	
	static String dbname = "emails";
	
	public static DBCollection list() {
		DB db=null;

		if (m == null) {
			try {
				//mongo staff.mongohq.com:10064/rewordpress -u
				
				m = new Mongo("ds049237.mongolab.com",49237);
				db = m.getDB(dbname);
				boolean auth = db.authenticate("vdc", "abcD1234".toCharArray());
				
			} catch (UnknownHostException e) {
				e.printStackTrace();
			} catch (MongoException e) {
				e.printStackTrace();
			}
		}

		db = m.getDB(dbname);
		DBCollection coll = db.getCollection(name);
		System.out.println(coll.count());
		return coll;
	}
}